<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>float64array.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_vec_float64array.js.html">float64array.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2011 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>
<a name="line16"></a>/**
<a name="line17"></a> * @fileoverview Supplies a Float64Array implementation that implements
<a name="line18"></a> * most of the Float64Array spec and that can be used when a built-in
<a name="line19"></a> * implementation is not available.
<a name="line20"></a> *
<a name="line21"></a> * Note that if no existing Float64Array implementation is found then this
<a name="line22"></a> * class and all its public properties are exported as Float64Array.
<a name="line23"></a> *
<a name="line24"></a> * Adding support for the other TypedArray classes here does not make sense
<a name="line25"></a> * since this vector math library only needs Float32Array and Float64Array.
<a name="line26"></a> *
<a name="line27"></a> */
<a name="line28"></a>goog.provide(&#39;goog.vec.Float64Array&#39;);
<a name="line29"></a>
<a name="line30"></a>
<a name="line31"></a>
<a name="line32"></a>/**
<a name="line33"></a> * Constructs a new Float64Array. The new array is initialized to all zeros.
<a name="line34"></a> *
<a name="line35"></a> * @param {goog.vec.Float64Array|Array|ArrayBuffer|number} p0
<a name="line36"></a> *     The length of the array, or an array to initialize the contents of the
<a name="line37"></a> *     new Float64Array.
<a name="line38"></a> * @constructor
<a name="line39"></a> * @final
<a name="line40"></a> */
<a name="line41"></a>goog.vec.Float64Array = function(p0) {
<a name="line42"></a>  this.length = /** @type {number} */ (p0.length || p0);
<a name="line43"></a>  for (var i = 0; i &lt; this.length; i++) {
<a name="line44"></a>    this[i] = p0[i] || 0;
<a name="line45"></a>  }
<a name="line46"></a>};
<a name="line47"></a>
<a name="line48"></a>
<a name="line49"></a>/**
<a name="line50"></a> * The number of bytes in an element (as defined by the Typed Array
<a name="line51"></a> * specification).
<a name="line52"></a> *
<a name="line53"></a> * @type {number}
<a name="line54"></a> */
<a name="line55"></a>goog.vec.Float64Array.BYTES_PER_ELEMENT = 8;
<a name="line56"></a>
<a name="line57"></a>
<a name="line58"></a>/**
<a name="line59"></a> * The number of bytes in an element (as defined by the Typed Array
<a name="line60"></a> * specification).
<a name="line61"></a> *
<a name="line62"></a> * @type {number}
<a name="line63"></a> */
<a name="line64"></a>goog.vec.Float64Array.prototype.BYTES_PER_ELEMENT = 8;
<a name="line65"></a>
<a name="line66"></a>
<a name="line67"></a>/**
<a name="line68"></a> * Sets elements of the array.
<a name="line69"></a> * @param {Array.&lt;number&gt;|Float64Array} values The array of values.
<a name="line70"></a> * @param {number=} opt_offset The offset in this array to start.
<a name="line71"></a> */
<a name="line72"></a>goog.vec.Float64Array.prototype.set = function(values, opt_offset) {
<a name="line73"></a>  opt_offset = opt_offset || 0;
<a name="line74"></a>  for (var i = 0; i &lt; values.length &amp;&amp; opt_offset + i &lt; this.length; i++) {
<a name="line75"></a>    this[opt_offset + i] = values[i];
<a name="line76"></a>  }
<a name="line77"></a>};
<a name="line78"></a>
<a name="line79"></a>
<a name="line80"></a>/**
<a name="line81"></a> * Creates a string representation of this array.
<a name="line82"></a> * @return {string} The string version of this array.
<a name="line83"></a> * @override
<a name="line84"></a> */
<a name="line85"></a>goog.vec.Float64Array.prototype.toString = Array.prototype.join;
<a name="line86"></a>
<a name="line87"></a>
<a name="line88"></a>/**
<a name="line89"></a> * Note that we cannot implement the subarray() or (deprecated) slice()
<a name="line90"></a> * methods properly since doing so would require being able to overload
<a name="line91"></a> * the [] operator which is not possible in javascript.  So we leave
<a name="line92"></a> * them unimplemented.  Any attempt to call these methods will just result
<a name="line93"></a> * in a javascript error since we leave them undefined.
<a name="line94"></a> */
<a name="line95"></a>
<a name="line96"></a>
<a name="line97"></a>/**
<a name="line98"></a> * If no existing Float64Array implementation is found then we export
<a name="line99"></a> * goog.vec.Float64Array as Float64Array.
<a name="line100"></a> */
<a name="line101"></a>if (typeof Float64Array == &#39;undefined&#39;) {
<a name="line102"></a>  try {
<a name="line103"></a>    goog.exportProperty(goog.vec.Float64Array, &#39;BYTES_PER_ELEMENT&#39;,
<a name="line104"></a>                        goog.vec.Float64Array.BYTES_PER_ELEMENT);
<a name="line105"></a>  } catch (float64ArrayError) {
<a name="line106"></a>    // Do nothing.  This code is in place to fix b/7225850, in which an error
<a name="line107"></a>    // is incorrectly thrown for Google TV on an old Chrome.
<a name="line108"></a>    // TODO(user): remove after that version is retired.
<a name="line109"></a>  }
<a name="line110"></a>
<a name="line111"></a>  goog.exportProperty(goog.vec.Float64Array.prototype, &#39;BYTES_PER_ELEMENT&#39;,
<a name="line112"></a>                      goog.vec.Float64Array.prototype.BYTES_PER_ELEMENT);
<a name="line113"></a>  goog.exportProperty(goog.vec.Float64Array.prototype, &#39;set&#39;,
<a name="line114"></a>                      goog.vec.Float64Array.prototype.set);
<a name="line115"></a>  goog.exportProperty(goog.vec.Float64Array.prototype, &#39;toString&#39;,
<a name="line116"></a>                      goog.vec.Float64Array.prototype.toString);
<a name="line117"></a>  goog.exportSymbol(&#39;Float64Array&#39;, goog.vec.Float64Array);
<a name="line118"></a>}
</pre>


</body>
</html>
